package com.rc.evcharger.biz.log;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.rc.evcharger.common.config.MqCommandConfig;
import com.rc.evcharger.common.mq.MqProducer;
import com.rc.evcharger.vo.log.ElecPileFaultRecordLog;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;

/**
 * 充电故障组装器
 * Created by yang on 2019-11-16
 */
@Component
public class ElecPileFaultRecordLogAssemble {
    private static Logger logger = LoggerFactory.getLogger(ElecPileFaultRecordLogAssemble.class);
    private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss,SSS");

    @Autowired
    private MqProducer mqProducer;

    @Autowired
    private MqCommandConfig mqCommandConfig;

    public void assembleTenantOperateLog(ElecPileFaultRecordLog log) {
        ObjectMapper objectMapper = new ObjectMapper();

        //推送日志消息
        try {
            String json = objectMapper.writeValueAsString(log);
            mqProducer.send(mqCommandConfig.getLOG_ELECPILE_FAULT(), json);
        } catch (Exception e) {
            logger.error("ElecPileFaultRecordLogAssemble推送日志消息报错", e);
        }
    }
}
